def sort_dic_print(a):
    dic1 = {'Tom':21,'Bob':18,'Jack':23,'Ana':20}
    dic2 = {'李雷':21,'韩梅梅':18,'小明':23,'小红':20}
    dic1_copy = sorted(dic1.keys())
    item = list(dic2.items())
    item.sort(key = lambda x:x[1])

    s1 = 4

    if(a <= s1):
        dic1_copy = list(dic1_copy)[:a]
        item = list(item)[:a]
        print(dic1_copy)
        print(item)
    else:
        print(dic1_copy)
        print(item)

a = int(input())

sort_dic_print(a)
